﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Runtime.Remoting;
using System.Text;

namespace Contracts
{
    [ServiceContract]
    public interface IMobileService
    {
        [OperationContract]
        [WebGet(UriTemplate = "GetString", ResponseFormat = WebMessageFormat.Json)]
        string GetString();

        [WebInvoke(Method = "GET",
                  ResponseFormat = WebMessageFormat.Json,
                  UriTemplate = "GetString2/{str}",
                  BodyStyle = WebMessageBodyStyle.Bare)]
        string GetString2(string str);

        [OperationContract]
        [WebGet(UriTemplate = "GetPerson", ResponseFormat = WebMessageFormat.Json)]
        Person GetPerson();

        [WebInvoke(Method = "GET",
                   ResponseFormat = WebMessageFormat.Json,
                   UriTemplate = "GetPerson2/{name}/{age}",
                   BodyStyle = WebMessageBodyStyle.Bare)]
        Person GetPerson2(string name, int age);
        [WebInvoke(Method = "GET",
                   ResponseFormat = WebMessageFormat.Json,
                   UriTemplate = "GetPerson3/{p}",
                   BodyStyle = WebMessageBodyStyle.Bare)]
        Person GetPerson3(Person p);

    }

    [DataContract]
    public class Person
    {
        public Person()
        {

        }

        public Person(string name, int age)
        {
            this.name = name;
            this.age = age;
        }

        string name;
        [DataMember(Order = 1)]
        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        int age;
        [DataMember(Order = 2)]
        public int Age
        {
            get { return age; }
            set { age = value; }
        }
    }
}
